import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.Arrays;

public class JavaTest {
    public static void main(String[] args) {
        System.out.println("lizhenyu 初来咋到");
        getInstance(a.class);

        int []nums = new int[]{21, 33, 12, 4, 22};
        System.out.println(Arrays.toString(nums));
        System.out.println(getMax(nums));
        System.out.println(Arrays.toString(nums));
    }

    static int getMax(int a[]) {
        int temp = 0;
        for (int i = 0; i < a.length - 1; i++) {
            if(a[i] > a[i + 1]) {
                temp = a[i];
                a[i] = a[i + 1];
                a[i + 1] = temp;
            }
        }
        return a[a.length - 1];
    }

    static class a{
        a(){
            System.out.println("aaa");
        }
        a(int aa, double b){
            System.out.println(aa + " -- " + b);
        }
        void b(int a) {
            System.out.println("cccc" + a);
        }
    }

    static class b{
        b(){
            System.out.println("bbb");
        }
    }

    public static void getInstance(Class clazz){
        try {
            Constructor constructor = clazz.getDeclaredConstructor();
            constructor.setAccessible(true);
            Object o = constructor.newInstance(new Object[]{});
            if(o instanceof a){
                System.out.println("its a");
            }
            Method method = clazz.getDeclaredMethod("b", new Class[]{int.class});
            Object obj = method.invoke(o, new Object[]{15});
            if(obj == null) {
                System.out.println("return is null");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}

